//
//  UINoneView.m
//  EOC营销通
//
//  Created by 吕韦 on 15/10/10.
//  Copyright © 2015年 尚通科技. All rights reserved.
//

#import "UINoneView.h"

@implementation UINoneView
{
    UILabel* lblTitle;
    UIImageView* newImage;
}

static UINoneView *sharedInstance = nil;
+ (UINoneView *)sharedInstance {
    if (sharedInstance == nil) {
        sharedInstance = [[UINoneView alloc]init];
    }
    return sharedInstance;
}

- (UINoneView *)showInview:(UIView*)view Title:(NSString*)title bgImageName:(NSString*)imageName BgColor:(UIColor*)color UploadHeight:(NSInteger)UploadHeight
{
    return [self showInview:view Title:title bgImageName:imageName BgColor:color UploadHeight:UploadHeight imageHeight:60];
}

- (UINoneView *)showInview:(UIView*)view Title:(NSString*)title bgImageName:(NSString*)imageName BgColor:(UIColor*)color UploadHeight:(CGFloat)UploadHeight imageHeight:(CGFloat)imageHeight
{
    self.frame = CGRectMake(0, UploadHeight, kScreenWidth, view.frame.size.height-UploadHeight);
//    if (UploadHeight != -REM_H(20) || UploadHeight != REM_H(500)) {
//        UploadHeight = -REM_H(120);
//        self.frame = CGRectMake(0, UploadHeight, kScreenwidth, view.frame.size.height+REM_H(120));
//    }
//    else
//    {
//    }
    if (color == nil) {
        //[self setBackgroundColor:[UIColor whiteColor]];
    }
    else
    {
        [self setBackgroundColor:color];
    }
    imageHeight = 120;
    [view addSubview:self];
    
    
    if (lblTitle == nil) {
        lblTitle = [[UILabel alloc]init];
//        lblTitle.textColor = AuxiliaryWordGrayColor;
        lblTitle.textColor = [UIColor lightGrayColor];
        lblTitle.textAlignment = NSTextAlignmentCenter;
        [lblTitle setFont:[UIFont systemFontOfSize:14]];
        lblTitle.numberOfLines = 0;
        lblTitle.lineBreakMode = NSLineBreakByWordWrapping;//换行
        [self addSubview:lblTitle];
    }
    if (newImage == nil) {
        newImage = [[UIImageView alloc]init];
        [self addSubview:newImage];
    }
    
    newImage.image = [UIImage imageNamed:imageName];
    if(newImage.image == nil)
        return nil;
    CGFloat imgwidth = (imageHeight/newImage.image.size.height)*newImage.image.size.width;
    
    newImage.frame = CGRectMake((self.width-imgwidth)/2, (self.height-imageHeight)/2-80 / kScale, imgwidth, imageHeight);
    lblTitle.frame = CGRectMake(40, newImage.frame.origin.y+newImage.frame.size.height, kScreenWidth-80, 50);
    
    
    
    lblTitle.text = title;
    
    
    return self;
}

//- (UINoneView *)showInview:(UIView*)view Title:(NSString*)title bgImageName:(NSString*)imageName BgColor:(UIColor*)color UploadHeight:(NSInteger)UploadHeight
//{
//    self.frame = CGRectMake(0, UploadHeight, view.frame.size.width, view.frame.size.height);
//    if (color == nil) {
//        [self setBackgroundColor:[UIColor whiteColor]];
//    }
//    else
//    {
//        [self setBackgroundColor:color];
//    }
//    
//    [view addSubview:self];
//    
//    
//    if (lblTitle == nil) {
//        lblTitle = [[UILabel alloc]init];
//        lblTitle.textColor = O_COLOR(220, 220, 220, 1);
//        lblTitle.textAlignment = NSTextAlignmentCenter;
//        [lblTitle setFont:Font(22)];
//        [self addSubview:lblTitle];
//    }
//    if (newImage == nil) {
//        newImage = [[UIImageView alloc]init];
//        [self addSubview:newImage];
//    }
//    
//    newImage.image = [UIImage imageNamed:imageName];
//    
//    newImage.frame = CGRectMake((view.frame.size.width-newImage.image.size.width)/2, 60, newImage.image.size.width, newImage.image.size.height);
//    
//    lblTitle.frame = CGRectMake(0, newImage.frame.origin.y+newImage.frame.size.height, kScreenwidth, 50);
//    
//    
//    
//    lblTitle.text = title;
//    
//    
//    return self;
//}
@end
